package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmExcelDictionaryDao;
import com.jy.modules.cims.data.common.dto.TCMmExcelDictionaryDTO;
import com.jy.platform.core.common.BaseDTO;

/**
 * @classname: TCMmExcelDictionaryService
 * @description: 定义  模板关联字段 实现类
 * @author:  JY-IT-D001
 */
@Service("com.jy.modules.cims.component.common.service.TCMmExcelDictionaryService")
public class TCMmExcelDictionaryService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmExcelDictionaryDao dao;

	/**
     * @author JY-IT-D001
     * @description: 分页查询 T_C_MM_EXCEL_DICTIONARY列表
     * @date 2015-01-06 17:33:11
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmExcelDictionaryDTO> searchTCMmExcelDictionaryByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmExcelDictionaryDTO> dataList =  dao.searchTCMmExcelDictionaryByPaging(searchParams);
		return dataList;
	}
	/**
     * @author JY-IT-D001
     * @description: 按条件查询T_C_MM_EXCEL_DICTIONARY列表
     * @date 2015-01-06 17:33:11
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmExcelDictionaryDTO> searchTCMmExcelDictionary(Map<String,Object> searchParams) throws Exception {
	    List<TCMmExcelDictionaryDTO> dataList = dao.searchTCMmExcelDictionary(searchParams);
        return dataList;
    }
	/**
     * @author JY-IT-D001
     * @description: 查询T_C_MM_EXCEL_DICTIONARY对象
     * @date 2015-01-06 17:33:11
     * @param id
     * @return
     * @throws
     */ 
	public TCMmExcelDictionaryDTO queryTCMmExcelDictionaryByPrimaryKey(String id) throws Exception {
		
		TCMmExcelDictionaryDTO dto = dao.findTCMmExcelDictionaryByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmExcelDictionaryDTO();
		
		return dto;
		
	}
	
	/**
	 * 
	 * @Title queryTCMmExcelDictionaryByTemplateCode
	 * @Description 通过模板编号查询模板字段对象
	 * @param templateCode
	 * @return
	 * @throws Exception 
	 * TCMmExcelDictionaryDTO 
	 * @date 2015-2-3-下午4:03:14
	 * @update 
	 * @throws
	 */
	public TCMmExcelDictionaryDTO queryTCMmExcelDictionaryByTemplateCode(String templateCode) throws Exception {
		
		List<TCMmExcelDictionaryDTO> dtolist = dao.findTCMmExcelDictionaryByTemplateCode(templateCode);
		
		if(dtolist!=null&&dtolist.size()>0)
			return dtolist.get(0);
		else
			return null;
	}
	
	/**
	 * 
	 * @param templateCode
	 * @return
	 * @throws Exception
	 */
	public List<TCMmExcelDictionaryDTO> queryTCMmExcelDictionaryByTemplateCodes(String templateCode) throws Exception {
		
		List<TCMmExcelDictionaryDTO> dto = dao.findTCMmExcelDictionaryByTemplateCodes(templateCode);
		
		return dto;
		
	}

	/**
     * @title: insertTCMmExcelDictionary
     * @author JY-IT-D001
     * @description: 新增 T_C_MM_EXCEL_DICTIONARY对象
     * @date 2015-01-06 17:33:11
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmExcelDictionary(TCMmExcelDictionaryDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmExcelDictionary(paramMap);
		
		TCMmExcelDictionaryDTO resultDto = (TCMmExcelDictionaryDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmExcelDictionary
     * @author JY-IT-D001
     * @description: 修改 T_C_MM_EXCEL_DICTIONARY对象
     * @date 2015-01-06 17:33:11
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmExcelDictionary(TCMmExcelDictionaryDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmExcelDictionary(paramMap);
	}
	/**
     * @title: deleteTCMmExcelDictionaryByPrimaryKey
     * @author JY-IT-D001
     * @description: 删除 T_C_MM_EXCEL_DICTIONARY,按主键
     * @date 2015-01-06 17:33:11
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmExcelDictionaryByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmExcelDictionaryByPrimaryKey(paramMap);
	}
	/**
	 * 
	 * @Title deleteTCMmExcelDictionaryByTemplateCode
	 * @Description TODO
	 * @param templateCode
	 * @throws Exception 
	 * void 
	 * @author lizhiqiang
	 * @date 2016-8-9-下午4:13:19
	 * @update 
	 * @throws
	 */
	public void deleteTCMmExcelDictionaryByTemplateCode(String templateCode) throws Exception {
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("templateCode", templateCode);
		dao.deleteTCMmExcelDictionaryByTemplateCode(paramMap);
	}

}

